Skip to content

Conversation

@m1kola
Copy link
Contributor

@m1kola m1kola commented May 6, 2020

Description

The changes in the original PR were a duplicate of #13315 which got merged recently. I rebased the PR and I updated it so we hopefully reduce the probability of AttributeError in the similar cases.

This checklist is used to make sure that common guidelines for a pull request are followed.

@m1kola m1kola requested a review from arrownj as a code owner May 6, 2020 10:57
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't seem like we ever had name and os_type attributes in the public API.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But this code been here since the beginning of times too. Not sure what broke the command.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @m1kola , is this because the different API version? Are you sure we can remove these code safely?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arrownj I'm currently not sure why it's happening. It was working fine on Azure CLI 2.3.1 (maybe on newer versions too) and az openshift show and az openshift list are broken on 2.5.1 and dev branch.

As far as I see, we did not change anything in the API and we never had name and os_type fields in the master pool profile API on the server (I checked all the supported versions in our codebase).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's the break:

Azure/azure-sdk-for-python@3f6238b#diff-66c3074fc0745e8946eba5783a5f8f32R21

The client library we were using was stale having been generated on an ancient pre-GA API and ^ brings us up to date.

@m1kola
Copy link
Contributor Author

m1kola commented May 6, 2020

@julienstroheker could you also please take a look?

@yonzhan yonzhan added this to the S169 - For Build milestone May 6, 2020
@yonzhan
Copy link
Collaborator

yonzhan commented May 6, 2020

add to S169

@yungezz yungezz added the AKS az aks/acs/openshift label May 7, 2020
Copy link
Member

@jim-minter jim-minter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm +1 on this change. Thanks @m1kola !

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's the break:

Azure/azure-sdk-for-python@3f6238b#diff-66c3074fc0745e8946eba5783a5f8f32R21

The client library we were using was stale having been generated on an ancient pre-GA API and ^ brings us up to date.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if getattr(managed_cluster, attr, None) is None:
if hasattr(managed_cluster, attr) and getattr(managed_cluster, attr) is None:

arguably ^ is better, but it doesn't really matter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If remember Python correctly getattr(managed_cluster, attr) still needs to be getattr(managed_cluster, attr, None). Otherwise there will be an exception in case when there is no attribute.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it makes sense. I'll update.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh. I see... hasattr :) Tired brain.

It was failing with a Python Traceback
@m1kola m1kola force-pushed the fixes_az_openshift_show branch from 76b3ae4 to 94afb75 Compare May 7, 2020 16:34
@m1kola
Copy link
Contributor Author

m1kola commented May 7, 2020

It looks like it is a duplicated of #13315

@m1kola m1kola changed the title [ACS] az openshift show: Fix Python Traceback {ACS} az openshift show/list: Refactoring to reduce the probability of AttributeError May 7, 2020
@m1kola
Copy link
Contributor Author

m1kola commented May 7, 2020

The changes in the original PR were a duplicate of #13315 which got merged recently. I rebased the PR and I updated it so we hopefully reduce the probability of AttributeError in the similar cases.

Please take another look.

@jim-minter
Copy link
Member

LGTM.

@arrownj arrownj merged commit 3c8bf29 into Azure:dev May 9, 2020
@m1kola m1kola deleted the fixes_az_openshift_show branch May 11, 2020 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AKS az aks/acs/openshift

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants